package main;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

import javax.swing.JFrame;

import interceptor.dataValid.AdminDataValid;
import interceptor.dataValid.GeneralManagerDataValid;
import interceptor.dataValid.SalesManagerDataValid;
import logic.AdminLogic;
import logic.GeneralManagerLogic;
import logic.SalesManagerLogic;
import logicInterface.AdminLogicInterface;
import logicInterface.GeneralManagerLogicInterface;
import logicInterface.SalesManagerLogicInterface;

public class Main {
	AdminLogicInterface adminLogic;
	GeneralManagerLogicInterface generalManagerLogic;
	SalesManagerLogicInterface salesManagerLogic;
	
	public Main(){
		System.out.println("start");

        try {
        	adminLogic=new AdminDataValid(new AdminLogic());
        	generalManagerLogic=new GeneralManagerDataValid(new GeneralManagerLogic());
        	salesManagerLogic=new SalesManagerDataValid(new SalesManagerLogic());
        	
			LocateRegistry.createRegistry(8888);
			
			Naming.bind("rmi://localhost:8888/adminLogic",adminLogic); 
			Naming.bind("rmi://localhost:8888/generalManagerLogic",generalManagerLogic);
			Naming.bind("rmi://localhost:8888/salesManagerLogic",salesManagerLogic);
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (AlreadyBoundException e) {
			e.printStackTrace();
		} 
        
	}

	public static void main(String[] args) {
		new Main();
	}

}
